package com.atguigu.jxc.controller;

import com.atguigu.jxc.domain.ServiceVO;
import com.atguigu.jxc.entity.DamageList;
import com.atguigu.jxc.entity.OverflowList;
import com.atguigu.jxc.entity.OverflowListGoods;
import com.atguigu.jxc.entity.User;
import com.atguigu.jxc.service.GoodsService;
import com.atguigu.jxc.service.OverflowListGoodsService;
import com.atguigu.jxc.service.OverflowListService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpSession;
import java.util.Map;

/**
 * @author dxt
 * @create 2025-07-16-21:12
 */
@RestController
@RequestMapping("/overflowListGoods")
public class OverflowListGoodsController {

    @Autowired
    private OverflowListGoodsService overflowListGoodsService;

    /**
     * 保存报溢单
     * @param overflowList 报溢单
     * @param overflowListGoodsStr 报溢单商品
     * @return
     */
    @PostMapping("/save")
    public ServiceVO save(OverflowList overflowList, String overflowListGoodsStr, HttpSession session){
        User user = (User) session.getAttribute("currentUser");
        Integer userId = user.getUserId();
        overflowList.setUserId(userId);
        overflowListGoodsService.save(overflowList,overflowListGoodsStr);
        return new ServiceVO(100,"保存成功",null);
    }

    /**
     * 查询报溢单
     * @param sTime 开始时间
     * @param eTime 结束时间
     * @return
     */
    @PostMapping("/list")
    public Map<String,Object> getList(String  sTime, String  eTime){
        return overflowListGoodsService.getList(sTime,eTime);
    }

    /**
     * 查询报损单商品
     * @param overflowListId 报溢单Id
     * @return
     */
    @PostMapping("/goodsList")
    public Map<String,Object> getGoodsList(Integer overflowListId){
        return overflowListGoodsService.getGoodsList(overflowListId);
    }
}
